// 数据双向绑定
// <input bind:change='bindChange' data-bind='form.name' />
export const vModel = (pageInstance, event, cb) => {
  let _dataset = event.currentTarget.dataset
  let _targetPath = _dataset.bind
  let _detail = event.detail
  let _val = ''
  // <input> detail 为 基本类型，<textarea> detail = {value: '1', cursor: 1}
  if (typeof _detail === 'object') {
    if (_detail.value != null) {
      _val = _detail.value
    } else {
      _val = _dataset.value
    }
  } else {
    _val = _detail
  }
  console.log({[_targetPath]: _val})
  pageInstance.setData({
    [_targetPath]: _val
  }, () => { // 成功回调
    cb && cb()
  })
}